package com.zego.wawaji.ui.play.bean;

import android.os.Parcel;
import android.os.Parcelable;

import com.zego.wawaji.base.data.BaseData;

import org.json.JSONObject;

/**
 * 初始化游戏配置
 * Created by Su on 2017/12/18.
 */
public class PlayInit extends BaseData implements Parcelable {
    private int catchPR;     // 抓中概率 100： 中，下面的数据舍弃；其他： 表示概率
    private int catchUpRand;
    private int catchUpConst;
    private int catchTopRand;
    private int catchTopConst;
    private int catchMoveRand;
    private int catchMoveConst;
    private int catchBigRand;
    private int catchBigConst;
    private int catchHeightRand;
    private int catchHeightConst;

    @Override
    public void parseJson(String jsonStr) {
        JSONObject jsonObject = getJsonObject(jsonStr);

        this.setCatchPR(jsonObject.optInt("CatchPR"));

        JSONObject catchUpJson = getJsonObject(jsonObject.optString("CatchUp"));
        this.setCatchUpRand(catchUpJson.optInt("Rand"));
        this.setCatchUpConst(catchUpJson.optInt("Const"));

        JSONObject catchTopJson = getJsonObject(jsonObject.optString("CatchTop"));
        this.setCatchTopRand(catchTopJson.optInt("Rand"));
        this.setCatchTopConst(catchTopJson.optInt("Const"));

        JSONObject catchMoveJson = getJsonObject(jsonObject.optString("CatchMove"));
        this.setCatchMoveRand(catchMoveJson.optInt("Rand"));
        this.setCatchMoveConst(catchMoveJson.optInt("Const"));

        JSONObject catchBigJson = getJsonObject(jsonObject.optString("CatchBig"));
        this.setCatchBigRand(catchBigJson.optInt("Rand"));
        this.setCatchBigConst(catchBigJson.optInt("Const"));

        JSONObject catchHeightJson = getJsonObject(jsonObject.optString("CatchHeight"));
        this.setCatchHeightRand(catchHeightJson.optInt("Rand"));
        this.setCatchHeightConst(catchHeightJson.optInt("Const"));
    }

    public int getCatchUpRand() {
        return catchUpRand;
    }

    public void setCatchUpRand(int catchUpRand) {
        this.catchUpRand = catchUpRand;
    }

    public int getCatchUpConst() {
        return catchUpConst;
    }

    public void setCatchUpConst(int catchUpConst) {
        this.catchUpConst = catchUpConst;
    }

    public int getCatchTopRand() {
        return catchTopRand;
    }

    public void setCatchTopRand(int catchTopRand) {
        this.catchTopRand = catchTopRand;
    }

    public int getCatchTopConst() {
        return catchTopConst;
    }

    public void setCatchTopConst(int catchTopConst) {
        this.catchTopConst = catchTopConst;
    }

    public int getCatchMoveRand() {
        return catchMoveRand;
    }

    public void setCatchMoveRand(int catchMoveRand) {
        this.catchMoveRand = catchMoveRand;
    }

    public int getCatchMoveConst() {
        return catchMoveConst;
    }

    public void setCatchMoveConst(int catchMoveConst) {
        this.catchMoveConst = catchMoveConst;
    }

    public int getCatchBigRand() {
        return catchBigRand;
    }

    public void setCatchBigRand(int catchBigRand) {
        this.catchBigRand = catchBigRand;
    }

    public int getCatchBigConst() {
        return catchBigConst;
    }

    public void setCatchBigConst(int catchBigConst) {
        this.catchBigConst = catchBigConst;
    }

    public int getCatchHeightRand() {
        return catchHeightRand;
    }

    public void setCatchHeightRand(int catchHeightRand) {
        this.catchHeightRand = catchHeightRand;
    }

    public int getCatchHeightConst() {
        return catchHeightConst;
    }

    public void setCatchHeightConst(int catchHeightConst) {
        this.catchHeightConst = catchHeightConst;
    }

    public int getCatchPR() {
        return catchPR;
    }

    public void setCatchPR(int catchPR) {
        this.catchPR = catchPR;
    }

    public PlayInit() {
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(this.catchPR);
        dest.writeInt(this.catchUpRand);
        dest.writeInt(this.catchUpConst);
        dest.writeInt(this.catchTopRand);
        dest.writeInt(this.catchTopConst);
        dest.writeInt(this.catchMoveRand);
        dest.writeInt(this.catchMoveConst);
        dest.writeInt(this.catchBigRand);
        dest.writeInt(this.catchBigConst);
        dest.writeInt(this.catchHeightRand);
        dest.writeInt(this.catchHeightConst);
    }

    protected PlayInit(Parcel in) {
        this.catchPR = in.readInt();
        this.catchUpRand = in.readInt();
        this.catchUpConst = in.readInt();
        this.catchTopRand = in.readInt();
        this.catchTopConst = in.readInt();
        this.catchMoveRand = in.readInt();
        this.catchMoveConst = in.readInt();
        this.catchBigRand = in.readInt();
        this.catchBigConst = in.readInt();
        this.catchHeightRand = in.readInt();
        this.catchHeightConst = in.readInt();
    }

    public static final Creator<PlayInit> CREATOR = new Creator<PlayInit>() {
        @Override
        public PlayInit createFromParcel(Parcel source) {
            return new PlayInit(source);
        }

        @Override
        public PlayInit[] newArray(int size) {
            return new PlayInit[size];
        }
    };
}
